import axios from "axios";
import { getItem } from "@/utils/localStorageUtils";

axios.defaults.timeout = 90000;
let baseUrl: string;
switch (document.domain) {
  case "":
    baseUrl="http://120.0.0.1:3000"
    break;
  default:
    baseUrl = "http://localhost:3000";
    break;
}
axios.defaults.baseURL = baseUrl;
/*请求拦截*/
axios.interceptors.request.use(
  function(config) {
    const token = getItem("TOKEN");
    if (token) {
      config.headers.set("token", token);
    }
    return config;
  },
  function(error) {
    return Promise.reject(error);
  }
);
export default axios;
